package hongcaosp.app.android.video.record;

import android.util.Log;

import hongcaosp.app.android.login.UserToken;
import hongcaosp.app.android.modle.DataCallBack;
import hongcaosp.app.android.modle.bean.SignBean;
import hongcaosp.app.android.modle.impl.VideoModleImpl;
import hongcaosp.app.android.modle.mi.VideoModle;
import xlj.lib.android.base.component.BasePresenter;

public class RecordVideoPresenter extends BasePresenter {
    private VideoModle videoModle;
    private IRecordView recordView;

    public RecordVideoPresenter(IRecordView recordView) {
        this.recordView = recordView;
        videoModle = new VideoModleImpl();
    }

    public void getSign() {
        videoModle.videoSign(UserToken.getDefault().getToken(), new DataCallBack<SignBean>() {
            @Override
            public void onGetData(SignBean data) {
                super.onGetData(data);
                recordView.freshSign(true,data.getSign());
            }

            @Override
            public void onFail(int code, String errorMessage) {
                super.onFail(code, errorMessage);
                Log.e("RecordVideoPresenter","获取sign失败 : " + errorMessage);
                recordView.freshSign(false,null);
            }
        });
    }

    public void publishVideo(String content,String videoPath,float videoSeconds,int videoWidth,int videoHeight,String coverPath) {
        videoModle.releaseVideos(UserToken.getDefault().getToken(), content, videoPath, videoSeconds, videoWidth, videoHeight, coverPath,
                new DataCallBack() {
            @Override
            public void onGetData(Object data) {
                super.onGetData(data);
                recordView.releaseVideo(true,null);
            }

            @Override
            public void onFail(int code, String errorMessage) {
                super.onFail(code, errorMessage);
                Log.e("RecordVideoPresenter","发布视频失败 : " + errorMessage);
                recordView.releaseVideo(false,errorMessage);
            }
        });
    }
}
